Skip to content

Add TweetClaw flow input recipe#11

Open
kriptoburak wants to merge 3 commits into
gumloop:mainfrom
kriptoburak:codex/add-tweetclaw-flow-recipe
Open

Add TweetClaw flow input recipe#11
kriptoburak wants to merge 3 commits into
gumloop:mainfrom
kriptoburak:codex/add-tweetclaw-flow-recipe

Conversation

@kriptoburak

Copy link
Copy Markdown

Summary

  • add a README recipe for passing TweetClaw JSON export data into a Gumloop flow
  • demonstrate list inputs with a small standard-library loader
  • keep SDK behavior unchanged

Validation

  • README Python sample parsed with ast.parse
  • npx --yes markdown-link-check README.md --quiet
  • git diff --check

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a documentation recipe to README.md showing how to parse a TweetClaw JSON export and pass the extracted tweet text as a list input to a Gumloop flow. No SDK or library code is changed.

  • The load_tweet_text helper handles multiple known top-level dict keys (tweets, data, results) and falls back to wrapping the root dict in a single-element list, addressing the previously noted silent-data-loss case.
  • A if not isinstance(tweets, list): return [] guard prevents iteration over non-list values, and the list comprehension safely validates each item with isinstance(item.get(\"text\"), str) before indexing.

Confidence Score: 5/5

Safe to merge — only documentation is touched, no SDK code is changed, and the recipe correctly handles the known TweetClaw JSON shapes.

The change is limited to a README code sample. The load_tweet_text helper properly handles the multi-key dict fallback that was flagged in a prior review, guards against non-list values, and the list comprehension validates each item before indexing. No functional code in the library is affected.

No files require special attention.

Important Files Changed

Filename Overview
README.md Adds a new "Run a Flow with Tweet Data" recipe that loads TweetClaw JSON exports and passes tweet text into a Gumloop flow; correctly handles dict top-level keys (tweets, data, results, fallback wrap) and guards against non-list values.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["load_tweet_text(path)"] --> B["json.loads(...)"]
    B --> C{isinstance records dict?}
    C -- Yes --> D{"'tweets' in records?"}
    D -- Yes --> E["tweets = records['tweets']"]
    D -- No --> F{"'data' in records?"}
    F -- Yes --> G["tweets = records['data']"]
    F -- No --> H{"'results' in records?"}
    H -- Yes --> I["tweets = records['results']"]
    H -- No --> J["tweets = [records]"]
    C -- No --> K["tweets = records"]
    E & G & I & J & K --> L{isinstance tweets list?}
    L -- No --> M["return []"]
    L -- Yes --> N["filter: isinstance(item, dict) and isinstance(item.get('text'), str)"]
    N --> O["return [item['text'] for ...]"]
    O --> P["client.run_flow(inputs={'tweets': ..., 'source': 'TweetClaw'})"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["load_tweet_text(path)"] --> B["json.loads(...)"]
    B --> C{isinstance records dict?}
    C -- Yes --> D{"'tweets' in records?"}
    D -- Yes --> E["tweets = records['tweets']"]
    D -- No --> F{"'data' in records?"}
    F -- Yes --> G["tweets = records['data']"]
    F -- No --> H{"'results' in records?"}
    H -- Yes --> I["tweets = records['results']"]
    H -- No --> J["tweets = [records]"]
    C -- No --> K["tweets = records"]
    E & G & I & J & K --> L{isinstance tweets list?}
    L -- No --> M["return []"]
    L -- Yes --> N["filter: isinstance(item, dict) and isinstance(item.get('text'), str)"]
    N --> O["return [item['text'] for ...]"]
    O --> P["client.run_flow(inputs={'tweets': ..., 'source': 'TweetClaw'})"]
Loading

Reviews (3): Last reviewed commit: "Respect empty TweetClaw arrays" | Re-trigger Greptile

Comment thread README.md Outdated

def load_tweet_text(path: str) -> list[str]:
records = json.loads(Path(path).read_text(encoding="utf-8"))
tweets = records.get("tweets", records) if isinstance(records, dict) else records

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Silent data loss when dict has no tweets key

When records is a dict that does not contain a "tweets" key, records.get("tweets", records) returns the dict itself. Iterating over a dict in Python yields its string keys, not its values, so isinstance(item, dict) will be False for every key, and the function silently returns []. Any user whose TweetClaw export is a dict with a different top-level key (e.g. "data", "results") will get an empty list with no warning.

@kriptoburak

Copy link
Copy Markdown
Author

Optional visibility note: if this is useful and you merge it after checks pass, feel free to share the PR on X/Twitter and tag or mention the X account name burakbayir. I can repost it to my 24k followers so more developers and power users can discover this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant